<template>
  <div>
    <template v-for="item in menu">
      <el-menu-item
        v-if="item.children?item.children.length===0:true"
        :index="item.navigateUrl"
        :key="item.id">
        <i :class="['menuIcon','fa', 'fa-' + item.img]"></i>
        <span slot="title">{{item.menuName}}</span>
      </el-menu-item>
      <el-submenu
        v-else
        :key="item.id"
        :index="item.navigateUrl || item.id">
        <template slot="title">
          <i :class="['menuIcon', 'fa', 'fa-' + item.img]"></i>
          <span slot="title"> {{item.menuName}} </span>
        </template>
        <s-menu :menu="item.children"></s-menu>
      </el-submenu>
    </template>
  </div>
</template>
<script>
  export default {
    name: 's-menu',
    props: {
      menu: { // menu 树
        type: Array,
        require: true,
      },
    },
  };
</script>

<style scoped lang="scss">
  .menuIcon{
    font-size: 14px;
    margin-right: 10px;
  }
</style>
